package com.sgzn.sgpay.enums;

import com.sgzn.sgpay.util.EnumUtil;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 设备操作类型
 * @author huangsenguang
 * @version Id: DeviceOperateTypeEnum.java, v 0.1 2018/6/20 18:27 huangsenguang Exp $$
 */
public enum DeviceOperateTypeEnum {
    UNBIND("1","设备解绑"),
    REGISTER("2","设备注册"),
    MODIFY("3","设备修改"),
    ;

    @Getter
    private String code;

    @Getter
    private String desc;

    private DeviceOperateTypeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    private static final Map<String, String> map = new HashMap<String, String>();

    static{
        for(DeviceOperateTypeEnum single : DeviceOperateTypeEnum.values()){
            map.put(single.code, single.desc);
        }
    }

    public static DeviceOperateTypeEnum resolve(String code) {
        return EnumUtil.resolveFromCode(code, DeviceOperateTypeEnum.class);
    }

    /**
     * 解释翻译
     * @param code
     * @return
     */
    public static final String explain(String code) {
        return map.get(code);
    }
}

